<!DOCTYPE html>
<html ng-app="demoApp">
<head>
  <script src="../node_modules/angular/angular.js"></script>
</head>
<body>
  <div ng-controller="demoController">
    <input type="text" ng-model="curTodoItem.content">
    <button ng-click="addTodo">Add</button>
    <ul>
      <li ng-repeat="item in todoList">
        {{ item.content }}
      </li>
    </ul>
  </div>

<script>
  angular.module('demoApp', [])
    .controller('demoController', ['$scope', '$http', function ($scope, $http) {
      $scope.todoList = [{ content: 'write a doc' }];
      $scope.curTodoItem = { content: '' };

      $scope.queryTodoList = function() {
        // 直接使用$http服务
        $http.get('query-todo-list').then(res => {
          // ...
        })
      }

      $scope.addTodo = function() {
        // 直接使用$http服务
        $http.post('add-todo', { data: $scope.curTodoItem }).then(res => {
          // ...
        })
      }
    }]);
</script>
</body>
</html>